<%@ Page AutoEventWireup="true" EnableEventValidation="false" CodeFile="AllocateVenues.aspx.cs" Inherits="Home_AllocateVenues"
    Language="C#" Theme="YUI" %>

<%@ Register Src="../UserControls/Menu.ascx" TagName="Menu" TagPrefix="uc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>PlacementManager: Allocate Venues</title>

    <script language="javascript" type="text/javascript">
     
    function showToolTip(e,text){ 
      var ToolTip = document.getElementById("ToolTip");
      ToolTip.innerHTML=text; 
      ToolTip.style.left=(e.clientX+15+document.body.scrollLeft)+'px'; 
      ToolTip.style.top=(e.clientY+document.body.scrollTop)+'px'; 
      ToolTip.style.display="block"; 
    } 
    function hideToolTip(){ 
        var ToolTip = document.getElementById("ToolTip");
        ToolTip.style.display="none"; 
    } 
    </script>

</head>
<body>
    <form id="form1" runat="server">
        <ajaxToolkit:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server" EnableScriptGlobalization="True">
        </ajaxToolkit:ToolkitScriptManager>
        <div id="ToolTip" style="position: absolute; z-index: 1000; text-align: left; display: none;">
        </div>
        <div id="doc3" class="yui-t3">
            <div id="hd">
                <asp:Panel ID="pnlMenu" runat="server">
                    <uc1:Menu ID="Menu1" runat="server"></uc1:Menu>
                </asp:Panel>
            </div>
            <div id="bd">
                <div class="yui-b">
                    <span style="font-size: large; font-weight: bold; float: left;">Manage Venue Allocations</span>
                    <h2>
                        Placement Periods</h2>
                    <asp:UpdatePanel ID="updtpnlPlacementGrid" runat="server" UpdateMode="Conditional">
                        <ContentTemplate>
                            <asp:DropDownList ID="ddUnitFilter" runat="server" AppendDataBoundItems="True" AutoPostBack="True"
                                CssClass="dropdownlist" DataSourceID="odsUnits" DataTextField="UnitCode" DataValueField="UnitId"
                                ToolTip="Units" Width="80px" OnSelectedIndexChanged="ddUnitFilter_SelectedIndexChanged">
                                <asp:ListItem Value="0">All</asp:ListItem>
                            </asp:DropDownList><asp:DropDownList ID="ddCampusFilter" runat="server" AppendDataBoundItems="True"
                                AutoPostBack="True" CssClass="dropdownlist" DataSourceID="odsCampuses" DataTextField="CampusCode"
                                DataValueField="CampusId" ToolTip="Campuses" Width="50px" OnSelectedIndexChanged="ddCampusFilter_SelectedIndexChanged">
                                <asp:ListItem Value="0">All</asp:ListItem>
                            </asp:DropDownList><asp:DropDownList ID="ddSemesterFilter" runat="server" AutoPostBack="True"
                                CssClass="dropdownlist" ToolTip="Semesters" OnSelectedIndexChanged="ddSemesterFilter_SelectedIndexChanged">
                                <asp:ListItem Value="0">All</asp:ListItem>
                                <asp:ListItem Value="1">S1</asp:ListItem>
                                <asp:ListItem Value="2">S2</asp:ListItem>
                            </asp:DropDownList><asp:DropDownList ID="ddYearFilter" runat="server" AutoPostBack="True"
                                CssClass="dropdownlist" ToolTip="Years" OnSelectedIndexChanged="ddYearFilter_SelectedIndexChanged">
                                <asp:ListItem Value="0">All</asp:ListItem>
                                <asp:ListItem>2007</asp:ListItem>
                                <asp:ListItem>2008</asp:ListItem>
                                <asp:ListItem>2009</asp:ListItem>
                                <asp:ListItem>2010</asp:ListItem>
                            </asp:DropDownList>
                            <asp:ObjectDataSource ID="odsUnits" runat="server" OldValuesParameterFormatString="original_{0}"
                                SelectMethod="SelectAllWDivisionId" TypeName="PlacementManager.UnitComponent">
                                <SelectParameters>
                                    <asp:SessionParameter Name="DivisionId" SessionField="DivisionId" Type="Int32" />
                                    <asp:Parameter DefaultValue="UnitCode" Name="sortExpression" Type="String" />
                                </SelectParameters>
                            </asp:ObjectDataSource>
                            <asp:ObjectDataSource ID="odsCampuses" runat="server" OldValuesParameterFormatString="original_{0}"
                                SelectMethod="SelectAll" TypeName="PlacementManager.CampusComponent">
                                <SelectParameters>
                                    <asp:Parameter DefaultValue="CampusCode" Name="sortExpression" Type="String" />
                                </SelectParameters>
                            </asp:ObjectDataSource>
                            <br />
                            <asp:GridView ID="gvPlacementTypes" runat="server" AllowPaging="True" AllowSorting="True"
                                AutoGenerateColumns="False" DataKeyNames="PlacementTypeId" DataSourceID="odsPlacementTypesView"
                                EmptyDataText="No placement types have been defined. Please use the form on the right to create a new placement type."
                                OnDataBound="gvPlacementTypes_DataBound" OnRowDataBound="gvPlacementTypes_RowDataBound"
                                OnSelectedIndexChanged="gvPlacementTypes_SelectedIndexChanged" PageSize="15"
                                SelectedIndex="0" SkinID="NavigationGrid">
                                <Columns>
                                    <asp:CommandField ButtonType="Image" SelectImageUrl="~/Images/Icons/edit.gif" ShowSelectButton="True" />
                                    <asp:BoundField DataField="UnitCode" HeaderText="Unit" SortExpression="UnitCode" />
                                    <asp:TemplateField HeaderText="Campus" SortExpression="CampusCode">
                                        <ItemTemplate>
                                            <asp:Label ID="lblCampus" runat="server" Text='<%# (Eval("CampusCode")) %>'></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:BoundField DataField="Year" HeaderText="Year" SortExpression="Year" />
                                    <asp:TemplateField HeaderText="Semester" SortExpression="SemesterId">
                                        <ItemTemplate>
                                            <asp:Label ID="lblSemester" runat="server" Text='<%# Eval("SemesterId") %>'></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="Name" SortExpression="PlacementTypeName">
                                        <ItemTemplate>
                                            <asp:Label ID="Label1" runat="server" Text='<%# Eval("PlacementTypeName").ToString() %>'></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                </Columns>
                            </asp:GridView>
        <asp:ObjectDataSource ID="odsPlacementTypesView" runat="server" OldValuesParameterFormatString="original_{0}"
            SelectMethod="SelectAllWFilters" SortParameterName="sortExpression" TypeName="PlacementManager.vwPlacementTypeComponent">
            <SelectParameters>
                <asp:Parameter DefaultValue="true" Name="isActive" Type="Boolean" />
                <asp:ControlParameter ControlID="ddUnitFilter" DefaultValue="0" Name="unitId" PropertyName="SelectedValue"
                    Type="Int32" />
                <asp:ControlParameter ControlID="ddCampusFilter" DefaultValue="0" Name="campusId"
                    PropertyName="SelectedValue" Type="Int32" />
                <asp:ControlParameter ControlID="ddSemesterFilter" DefaultValue="0" Name="semesterId"
                    PropertyName="SelectedValue" Type="Int32" />
                <asp:ControlParameter ControlID="ddYearFilter" DefaultValue="0" Name="year" PropertyName="SelectedValue"
                    Type="Int32" />
                <asp:Parameter DefaultValue="0" Name="categoryId" Type="Int32" />
                <asp:Parameter DefaultValue="DateCreated" Name="sortExpression" Type="String" />
            </SelectParameters>
        </asp:ObjectDataSource>
                        </ContentTemplate>
                    </asp:UpdatePanel>
                </div>
                <div id="yui-main">
                    <div class="yui-b">
                        <asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="updtpnlPlacementGrid"
                            DisplayAfter="2" DynamicLayout="false">
                            <ProgressTemplate>
                                &nbsp; &nbsp;&nbsp;
                                <img alt="Progress" src="../Images/progressbar_long_green.gif" />
                            </ProgressTemplate>
                        </asp:UpdateProgress>
                        <div class="yui-g">
                            <div class="yui-u first">
                                <h2>
                                    Available Venues</h2>
                                <asp:UpdatePanel ID="updtpnlAvailableVenues" runat="server" UpdateMode="Conditional">
                                    <Triggers>
                                        <asp:AsyncPostBackTrigger ControlID="gvPlacementTypes" EventName="SelectedIndexChanged" />
                                        <asp:AsyncPostBackTrigger ControlID="ddCampusFilter" EventName="SelectedIndexChanged" />
                                        <asp:AsyncPostBackTrigger ControlID="ddSemesterFilter" EventName="SelectedIndexChanged" />
                                        <asp:AsyncPostBackTrigger ControlID="ddUnitFilter" EventName="SelectedIndexChanged" />
                                        <asp:AsyncPostBackTrigger ControlID="ddYearFilter" EventName="SelectedIndexChanged" />
                                        <asp:AsyncPostBackTrigger ControlID="gvPlacementTypes" EventName="PageIndexChanging" />
                                        <asp:AsyncPostBackTrigger ControlID="gvPlacementTypes" EventName="DataBound" />
                                        <asp:AsyncPostBackTrigger ControlID="gvPlacementTypes" EventName="Sorted" />
                                        <asp:AsyncPostBackTrigger ControlID="btnCheckedVenuesAction" EventName="Click" />
                                    </Triggers>
                                    <ContentTemplate>
                                        <asp:DropDownList ID="ddShowVenues" runat="server" AutoPostBack="True" CssClass="dropdownlist"
                                            OnSelectedIndexChanged="ddShowVenues_SelectedIndexChanged">
                                            <asp:ListItem Value="0">Venues Associated With Unit And Campus</asp:ListItem>
                                            <asp:ListItem Value="1">Venues Associated With Unit</asp:ListItem>
                                            <asp:ListItem Value="2">Venues Associated With Category</asp:ListItem>
                                            <asp:ListItem Value="3">All Venues</asp:ListItem>
                                        </asp:DropDownList><br />
                                        <asp:Button ID="btnAddCheckedVenues" runat="server" CssClass="inputbutton" OnClick="btnAddCheckedVenues_Click"
                                            Text="Add Checked Venues" />
                                        <asp:GridView ID="gvAvailableVenues" runat="server" AllowPaging="True" AutoGenerateColumns="False"
                                            DataKeyNames="VenueId" DataSourceID="odsAvailableVenuesAssocWUnitWCampus" EmptyDataText="There are no venues available to add for this placement type."
                                            OnRowDataBound="gvAvailableVenues_RowDataBound" ShowHeader="False" SkinID="AvailableGrid" PageSize="14">
                                            <Columns>
                                                <asp:HyperLinkField DataNavigateUrlFields="VenueId" DataNavigateUrlFormatString="Venues.aspx?id={0}"
                                                    DataTextField="VenueName" NavigateUrl="Venues.aspx" />
                                                <asp:TemplateField>
                                                    <ItemTemplate>
                                                        <asp:CheckBox ID="RowLevelCheckBox" runat="server" />
                                                    </ItemTemplate>
                                                </asp:TemplateField>
                                            </Columns>
                                        </asp:GridView>
                                    </ContentTemplate>
                                </asp:UpdatePanel>
                            </div>
                            <div class="yui-u">
                                <h2>
                                    Allocated Venues</h2>
                                <asp:UpdatePanel ID="updtpnlAllocatedVenues" runat="server" UpdateMode="Conditional">
                                    <Triggers>
                                        <asp:AsyncPostBackTrigger ControlID="btnAddCheckedVenues" EventName="Click" />
                                        <asp:AsyncPostBackTrigger ControlID="gvPlacementTypes" EventName="SelectedIndexChanged" />
                                        <asp:AsyncPostBackTrigger ControlID="ddUnitFilter" EventName="SelectedIndexChanged" />
                                        <asp:AsyncPostBackTrigger ControlID="ddCampusFilter" EventName="SelectedIndexChanged" />
                                        <asp:AsyncPostBackTrigger ControlID="ddSemesterFilter" EventName="SelectedIndexChanged" />
                                        <asp:AsyncPostBackTrigger ControlID="ddYearFilter" EventName="SelectedIndexChanged" />
                                        <asp:AsyncPostBackTrigger ControlID="gvPlacementTypes" EventName="PageIndexChanged" />
                                        <asp:AsyncPostBackTrigger ControlID="gvPlacementTypes" EventName="DataBound" />
                                        <asp:AsyncPostBackTrigger ControlID="gvPlacementTypes" EventName="Sorted" />
                                    </Triggers>
                                    <ContentTemplate>
                                        I want to
                                        <asp:DropDownList ID="ddCheckedVenueAction" runat="server" ToolTip="Select the action that you wish to take with checked venues" CssClass="dropdownlist">
                                            <asp:ListItem>Remove</asp:ListItem>
                                            <asp:ListItem>Confirm</asp:ListItem>
                                            <asp:ListItem>Unconfirm</asp:ListItem>
                                        </asp:DropDownList>
                                        checked venues
                                        <asp:Button ID="btnCheckedVenuesAction" runat="server" CssClass="inputbutton" OnClick="btnCheckedVenuesAction_Click"
                                            Text="Run" />
                                        <ajaxToolkit:ConfirmButtonExtender ID="cfbCheckedVenueAction" runat="server" ConfirmText="Are you sure that you want to carry out this action on these venues?"
                                            TargetControlID="btnCheckedVenuesAction">
                                        </ajaxToolkit:ConfirmButtonExtender>
                                        <br />
                                        &nbsp;<asp:CheckBox ID="cbShowAddressToolTip" runat="server" OnCheckedChanged="cbShowAddressToolTip_CheckedChanged"
                                            Text="Show Address Tooltip" />
                                        <asp:GridView ID="gvVenues" runat="server" AutoGenerateColumns="False" DataKeyNames="VenuePlacementTypeId"
                                            DataSourceID="odsAllocatedVenues" EmptyDataText="There are no venues" OnDataBound="gvVenues_DataBound"
                                            OnPageIndexChanged="gvVenues_PageIndexChanged" OnPageIndexChanging="gvVenues_PageIndexChanging"
                                            OnRowDataBound="gvVenues_RowDataBound" OnRowUpdated="gvVenues_RowUpdated" OnRowUpdating="gvVenues_RowUpdating"
                                            OnSelectedIndexChanged="gvVenues_SelectedIndexChanged" ShowHeader="False" SkinID="AllocatedGrid">
                                            <Columns>
                                                <asp:CommandField ButtonType="Button" ShowEditButton="True">
                                                    <ItemStyle VerticalAlign="Top" />
                                                    <ControlStyle CssClass="inputbutton" />
                                                </asp:CommandField>
                                                <asp:TemplateField HeaderText="VenuePlacementTypeId" SortExpression="VenuePlacementTypeId">
                                                    <ItemTemplate>
                                                        <asp:Label ID="lblVenueNameDetails" runat="server" Text='<%# GetVenueDetails(Eval("VenuePlacementTypeId").ToString()) %>'></asp:Label>
                                                        <br />
                                                        <asp:Label ID="lblConfirmed" runat="server" CssClass="message" Text='<%# GetConfirmedStatus(Eval("IsConfirmedByVenue").ToString()) %>'></asp:Label>
                                                    </ItemTemplate>
                                                    <ItemStyle Wrap="False" />
                                                    <EditItemTemplate>
                                                        <asp:Label ID="lblEditVenueNameDetails" runat="server" Text='<%# GetVenueDetails(Eval("VenuePlacementTypeId").ToString()) %>'></asp:Label><br />
                                                        <asp:CheckBox ID="cbIsRestricted" runat="server" Checked='<%# Bind("IsRestricted") %>'
                                                            Text="Restricted Places" /><br />
                                                        Num. Places:<asp:TextBox ID="txtMaxPlaces" runat="server" MaxLength="3" Text='<%# Bind("MaxNumStudents") %>'
                                                            Width="30px"></asp:TextBox>
                                                        <ajaxToolkit:FilteredTextBoxExtender ID="FilteredTextBoxExtender1" runat="server"
                                                            FilterType="Numbers" TargetControlID="txtMaxPlaces">
                                                        </ajaxToolkit:FilteredTextBoxExtender>
                                                        <br />
                                                        <asp:CheckBox ID="cbVenueSuppliedEducator" runat="server" Checked='<%# Bind("VenueSuppliedEducator") %>'
                                                            Text="Venue Supplies Educator" /><br />
                                                        <asp:CheckBox ID="cbIsVenueCharge" runat="server" Checked='<%# Bind("IsVenueCharge") %>'
                                                            Text="Venue Charges" /><br />
                                                        <asp:TextBox ID="txtChargeAmount" runat="server" Text='<%# Bind("ChargeAmount","{0:F2}") %>'
                                                            Width="40px"></asp:TextBox>
                                                        <br />
                                                        <asp:CheckBox ID="cbEditIsConfirmed" runat="server" Checked='<%# Bind("IsConfirmedByVenue") %>'
                                                            Text="Confirmed By Venue" />
                                                    </EditItemTemplate>
                                                </asp:TemplateField>
                                                <asp:TemplateField>
                                                    <ItemTemplate>
                                                        <asp:CheckBox ID="RowLevelCheckBox" runat="server" Enabled='<%# CheckIfStudentsAllocated(Eval("VenuePlacementTypeId").ToString()) %>' />
                                                    </ItemTemplate>
                                                    <ItemStyle VerticalAlign="Top" />
                                                </asp:TemplateField>
                                            </Columns>
                                            <EmptyDataTemplate>
                                                No venues have been allocated for this placement type.
                                            </EmptyDataTemplate>
                                            <PagerSettings Position="TopAndBottom" />
                                        </asp:GridView>
                                    </ContentTemplate>
                                </asp:UpdatePanel>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div id="ft">
                &nbsp;
            </div>
        </div>
        <!--
    ********************************************************************* 
    Object Data Sources 
    ********************************************************************* 
    -->
        <asp:ObjectDataSource ID="odsAllocatedVenues" runat="server" DataObjectTypeName="PlacementManager.LinkVenuePlacementType" OldValuesParameterFormatString="original_{0}"
            SelectMethod="SelectAllWPlacementTypeIdActiveOrdered" TypeName="PlacementManager.LinkVenuePlacementTypeComponent"
            UpdateMethod="Update">
            <SelectParameters>
                <asp:ControlParameter ControlID="gvPlacementTypes" DefaultValue="0" Name="PlacementTypeId"
                    PropertyName="SelectedValue" Type="Int32" />
            </SelectParameters>
        </asp:ObjectDataSource>
        <asp:ObjectDataSource ID="odsAvailableVenues" runat="server" OldValuesParameterFormatString="original_{0}"
            SelectMethod="SelectAllAvailableWPlacementTypeId" TypeName="PlacementManager.VenueComponent">
            <SelectParameters>
                <asp:ControlParameter ControlID="gvPlacementTypes" DefaultValue="1" Name="placementTypeId"
                    PropertyName="SelectedValue" Type="Int32" />
                <asp:Parameter DefaultValue="VenueName" Name="sortExpression" Type="String" />
            </SelectParameters>
        </asp:ObjectDataSource>
        <asp:ObjectDataSource ID="odsAvailableVenuesAssocWCategory" runat="server" OldValuesParameterFormatString="original_{0}"
            SelectMethod="SelectAllAvailableAssocWCategoryWPlacementTypeId" TypeName="PlacementManager.VenueComponent">
            <SelectParameters>
                <asp:ControlParameter ControlID="gvPlacementTypes" DefaultValue="1" Name="placementTypeId"
                    PropertyName="SelectedValue" Type="Int32" />
                <asp:Parameter DefaultValue="VenueName" Name="sortExpression" Type="String" />
            </SelectParameters>
        </asp:ObjectDataSource>
        <asp:ObjectDataSource ID="odsAvailableVenuesAssocWUnitWCampus" runat="server" OldValuesParameterFormatString="original_{0}"
            SelectMethod="SelectAllAvailableAssocWUnitWCampusWPlacementTypeId" TypeName="PlacementManager.VenueComponent">
            <SelectParameters>
                <asp:ControlParameter ControlID="gvPlacementTypes" DefaultValue="0" Name="placementTypeId"
                    PropertyName="SelectedValue" Type="Int32" />
                <asp:Parameter DefaultValue="VenueName" Name="sortExpression" Type="String" />
            </SelectParameters>
        </asp:ObjectDataSource>
        <asp:ObjectDataSource ID="odsAvailableVenuesAssocWUnit" runat="server" OldValuesParameterFormatString="original_{0}"
            SelectMethod="SelectAllAvailableAssocWUnitWPlacementTypeId" TypeName="PlacementManager.VenueComponent">
            <SelectParameters>
                <asp:ControlParameter ControlID="gvPlacementTypes" DefaultValue="1" Name="placementTypeId"
                    PropertyName="SelectedValue" Type="Int32" />
                <asp:Parameter DefaultValue="VenueName" Name="sortExpression" Type="String" />
            </SelectParameters>
        </asp:ObjectDataSource>
        <asp:ObjectDataSource ID="odsCategories" runat="server" OldValuesParameterFormatString="original_{0}"
            SelectMethod="SelectAllWDivisionId" TypeName="PlacementManager.CategoryComponent">
            <SelectParameters>
                <asp:SessionParameter Name="DivisionId" SessionField="DivisionId" Type="Int32" />
                <asp:Parameter DefaultValue="CategoryName" Name="sortExpression" Type="String" />
            </SelectParameters>
        </asp:ObjectDataSource>
    </form>
</body>
</html>
